<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>景旭商城-我的积分</title>
<%@ include file="/page/pc/include.jsp"%>
<!-- Bootstrap-select -->
<link rel="stylesheet" type="text/css" href="<%=basePath%>/statics/plugins/bootstrap-select-1.12.3/css/bootstrap-select.min.css" />
<!-- Bootstrap-select -->
<script type="text/javascript" src="<%=basePath%>/statics/plugins/bootstrap-select-1.12.3/js/bootstrap-select.min.js"></script>
</head>
<body>
	<div class="wrap">
		<jsp:include page="../_my_header.jsp" />
		<div class="site_wrap18">
			<div class="site_wrap18_con">
				<div class="main">
					<jsp:include page="../_my_left.jsp" />
					<div class="rightitem">

						<div class="wdjf_part">
							<div class="hd">
								<h3>我的积分</h3>
							</div>
							<div class="bd">
								<div class="jf_part1">
									<h1>我的积分</h1>
									<h2>
										<strong> <img src="<%=basePath%>/statics/images/icon_jifen1.png" />
										</strong> <span><fmt:formatNumber type="number" value="${point }" pattern="0.00" maxFractionDigits="2" /></span>
									</h2>
									<h3 id="sign_li">
										<a href="#" onclick="javascript: doSignAndReload();">签到领积分</a>
									</h3>
								</div>
								<div class="jf_part2">
									<div class="jf_part2_con">
										<div class="hd1">
											<h3>积分记录</h3>
										</div>
										<div class="bd1">
											<form action="<%=basePath%>/pc/my/point" id="pointLogForm" name="pointLogForm" method="post">
												<%-- 隐藏域 --%>
												<input type="hidden" id="pointOptType" value="${operateType }">
												<table>
													<thead>
														<tr>
															<td>时间</td>
															<td>积分</td>
															<td>
																<select class="select1" onchange="javascript: doReloadPoint();" style="width: 120px; font-size: 14px;height:30px;" id="operateType" name="operateType">
																	<option value="">操作类型</option>
																</select>
															</td>
															<!-- <td>积分余额</td> -->
															<td>备注</td>
														</tr>
													</thead>
													<tbody>
													<c:choose>
														<c:when test="${empty pointList }">
															<tr>
																<td colspan="4" >
																	<div class="hd1" style="text-align:center;">
																		<h4>暂无积分记录！</h4>
																	</div>
																</td>
															</tr>
														</c:when>
														<c:otherwise>
																<c:forEach items="${pointList }" var="pointLog">
																	<tr>
																		<td><fmt:formatDate value="${pointLog.operateTime }" type="date" /></td>
																		<td>
																			<c:choose>
																				<c:when test="${pointLog.operateFlag == 1 }">
																					<span class="a1">+ ${pointLog.operatePoint }</span>
																				</c:when>
																				<c:otherwise>
																					<span class="a2">- ${pointLog.operatePoint }</span>
																				</c:otherwise>
																			</c:choose>
																		</td>
																		<td>
																			<c:choose>
																				<c:when test="${pointLog.operateType eq 1 }">购买赠送</c:when>
																				<c:when test="${pointLog.operateType eq 2 }">签到赠送</c:when>
																				<c:when test="${pointLog.operateType eq 3 }">人工赠送</c:when>
																				<c:when test="${pointLog.operateType eq 4 }">购买消费</c:when>
																				<c:when test="${pointLog.operateType eq 5 }">人工核减</c:when>
																				<c:when test="${pointLog.operateType eq 6 }">到期限清零</c:when>
																				<c:when test="${pointLog.operateType eq 7 }">撤单退回</c:when>
																				<c:when test="${pointLog.operateType eq 8 }">审核不通过退回</c:when>
																				<c:when test="${pointLog.operateType eq 9 }">月度订单积分</c:when>
																				<c:when test="${pointLog.operateType eq 10 }">注册赠送</c:when>
																				<c:when test="${pointLog.operateType eq 11 }">绑定号码赠送</c:when>
																				<c:when test="${pointLog.operateType eq 12 }">分享赠送</c:when>
																				<c:when test="${pointLog.operateType eq 13 }">抽奖消耗</c:when>
																				<c:when test="${pointLog.operateType eq 14 }">积分变更</c:when>
																				<c:when test="${pointLog.operateType eq 15 }">退货积分调整</c:when>
																				<c:when test="${pointLog.operateType eq 16 }">人工赠送(导入)</c:when>
																				<c:when test="${pointLog.operateType eq 17 }">人工核减(导入)</c:when>
																				<c:when test="${pointLog.operateType eq 18 }">订单积分扣减</c:when>
																				<c:when test="${pointLog.operateType eq 19 }">订单积分增加</c:when>
																				<c:when test="${pointLog.operateType eq 20 }">活动赠送</c:when>
																				<c:otherwise>其他</c:otherwise>
																			</c:choose>
																		</td>
																		<%-- <td>${pointLog.afterPoint }</td> --%>
																		<td>
																			<c:if test="${not empty pointLog.operateUser }">操作人：${pointLog.operateUser }<br/></c:if>
																			<c:if test="${not empty pointLog.billCode }">订单号：<label style="color:red;">${pointLog.billCode }</label> <br/></c:if>
																			${pointLog.adjustReason }
																		</td>
																	</tr>
																</c:forEach>
															</c:otherwise>
														</c:choose>
													</tbody>
												</table>
											</form>
											<jx:paging formID="pointLogForm" isShowJumpToButton="true" numPerPage="10" isShowpageCount="true"></jx:paging>
										</div>
									</div>
								</div>
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>

	<div>
		<!---网站底部开始-->
		<jsp:include page="../../footer.jsp?showQaFlag=0" />
		<!---网站底部结束-->
	</div>
<script type="text/javascript">
	/**
	 * 定义下拉列表加载
	 */
	var selectpicker = function(config) {
		if (typeof config == 'object') {
			if (!config['id'] || !config['url']) {
				return false;
			}
			var defaults = {
				param : {},
				defaultValue : null,
				valueField : 'id',
				textField : 'text',
				defaultAll : false,
				async : true, // 默认异步加载
				loadSuccess : function(data) {
				} // 数据加载成功的回调事件
			};
			config = $.extend(defaults, config || {});
			var $select = $('#' + config.id);
			$.ajax({
				type : 'post',
				url : config.url,
				async : config.async,
				data : config.param,
				dataType : 'json',
				success : function(result) {
					$select.html('');
					if (config.defaultAll) {
						$select.append('<option value="" >--操作类型--</option>');
					}
					var data = result.data || result.rows || result.list || result;
					$.each(data, function(index, row) {
						var value = row[config.valueField];
						var text = row[config.textField];
						if(config.defaultValue && value == config.defaultValue) {
							$select.append('<option value="' + value + '" selected="selected" >' + text + '</option>');
						} else {
							$select.append('<option value="' + value + '" >' + text + '</option>');
						}
					});
					//数据加载成功之后的回调事件
					config.loadSuccess(data); 
				}
			})
		}
	};
	
	/**
	 * 重新加载页面
	 */
	function doReloadPoint() {
		
		$("#pointOptType").val($("#operateType").val());
		
		$("#pointLogForm").submit();
	}
		
		
		
		
	$(function() {
		//当日是否允许签到
		$.ajax({
			type : "post",
			url :  rootPath + "/home/checkAllowSign",
			async : true,
			datatype : "json",
			success : function(json) {
				if (json.allowSign != 1) {
					$("#sign_li").remove();
				}
			}
		});
		var pointOptType = $("#pointOptType").val();
		selectpicker({
			id : 'operateType', // select的id
			url : rootPath + "/dict/listKeyMapEntites", // 请求数据的远程地址
			param : {
				keyType : 'pointOptType'
			}, // 过滤参数
			valueField : 'keyValue',
			textField : 'keyIntro',
			defaultAll : true,
			defaultValue : pointOptType
		});
	});
	function doSignAndReload() {
		$.ajax({
			type : "post",
			url : '<%=basePath%>/home/doSign',
			async : false,
			datatype : "json",
			success : function(json) {
				if (json.code == '1') {
					layer.msg(json.msg, function() {
						window.location.reload();
					}, {icon:1,time:1000});
				} else {
					layer.msg(json.msg, {
						time : 3000
					});
				}
			},
			error : function() {
				layer.msg('暂时无法签到', {
					time : 1000
				});
			}
		});
	}
	</script>
	
</body>
</html>